
#include <BComboBox>
#include "member_BComboBox.h"
#include "member_BComboItem.h"

using namespace BWE;

#define member					(*(member_BComboItem*)_ptr)
#define member_allocate()		_ptr = new member_BComboItem(this)
#define member_release()		delete (member_BComboItem*)_ptr

BComboItem::BComboItem(const BValue& value)
{
	member_allocate();
	member.value = value;
}
BComboItem::BComboItem(const BString& text, const BValue& value)
{
	member_allocate();
	member.text = text;
	member.value = value;
}
BComboItem::BComboItem(BIcon* icon, const BString& text, const BValue& value)
{
	member_allocate();
	member.icon = icon;
	member.text = text;
	member.value = value;
}
BComboItem::BComboItem(BImage* image, const BString& text, const BValue& value)
{
	member_allocate();
	member.image = image;
	member.text = text;
	member.value = value;
}
BComboItem::BComboItem(Graph graph, const BString& text, const BValue& value)
{
	member_allocate();
	member.graph = graph;
	member.text = text;
	member.value = value;
}
BComboItem::~BComboItem()
{
	member_release();
}

void BComboItem::setText(const BString& text)
{
	if (member.text != text)
	{
		member.text = text;
	}
}
const BString& BComboItem::text() const
{
	return member.text;
}

void BComboItem::setIcon(BIcon* icon)
{
	if (member.icon != icon)
	{
		member.icon = icon;
	}
}
BIcon* BComboItem::icon() const
{
	return member.icon;
}

void BComboItem::setImage(BImage* image)
{
	if (member.image != image)
	{
		member.image = image;
	}
}
BImage* BComboItem::image() const
{
	return member.image;
}

void BComboItem::setGraph(Graph graph)
{
	if (member.graph != graph)
	{
		member.graph = graph;
	}
}
Graph BComboItem::graph() const
{
	return member.graph;
}

void BComboItem::setColor(BByte r, BByte g, BByte b, BByte a)
{
	setColor(BColor(r, g, b, a));
}
void BComboItem::setColor(const BColor& color)
{
	if (member.color != color)
	{
		member.color = color;
	}
}
const BColor& BComboItem::color() const
{
	return member.color;
}

void BComboItem::setValue(const BValue& value)
{
	if (member.value != value)
	{
		member.value = value;
	}
}
const BValue& BComboItem::value() const
{
	return member.value;
}

int BComboItem::index() const
{
	if (member.combo)
	{
		for (int i = 0; i < member.combo->itemCount(); i++)
		{
			if (member.combo->item(i) == this)
				return i;
		}
	}
	return -1;
}

BComboBox* BComboItem::comboBox()
{
	return member.combo;
}
const BComboBox* BComboItem::comboBox() const
{
	return member.combo;
}

